package businesslogic.courseselectionbl.Strategy;

import po.CourseClassification;
import po.CourseSelectionPO;
import po.Institute;
import po.LessonPO;

public class QuitStrategy {
	private boolean[] canQuit = new boolean[8];
	private boolean[] canCancelSelect = new boolean[8];
	private static QuitStrategy qs;
	
	private QuitStrategy() {
		canQuit[CourseClassification.BIYELUNWEN.ordinal()] = false; //abs
		canQuit[CourseClassification.FENCENGCITONGXIUKE.ordinal()] = false; //abs
		canQuit[CourseClassification.GONGGONGXUANXIUKE.ordinal()] = true; 
		canQuit[CourseClassification.JUNSHIKE.ordinal()] = false; //abs
		canQuit[CourseClassification.SIXIANGZHENGZHILILUNKE.ordinal()] = false; //abs
		canQuit[CourseClassification.TONGSHIJIAOYUKE.ordinal()] = true;
		canQuit[CourseClassification.ZHUANYEKE.ordinal()] = false;	//not abs
		canQuit[CourseClassification.ZHUANYEXUANXIUKE.ordinal()] = true;
		
		
		canCancelSelect[CourseClassification.BIYELUNWEN.ordinal()] = false; //abs
		canCancelSelect[CourseClassification.FENCENGCITONGXIUKE.ordinal()] = false; //abs
		canCancelSelect[CourseClassification.GONGGONGXUANXIUKE.ordinal()] = true; 
		canCancelSelect[CourseClassification.JUNSHIKE.ordinal()] = false; //abs
		canCancelSelect[CourseClassification.SIXIANGZHENGZHILILUNKE.ordinal()] = false; //abs
		canCancelSelect[CourseClassification.TONGSHIJIAOYUKE.ordinal()] = true;
		canCancelSelect[CourseClassification.ZHUANYEKE.ordinal()] = true;	//not abs
		canCancelSelect[CourseClassification.ZHUANYEXUANXIUKE.ordinal()] = false;
	}
	
	public boolean canQuit(CourseSelectionPO po) {
		Institute studentIns = po.getStudentPO().getInstitute();
		LessonPO lesson = po.getLessonPO();
		CourseClassification t = lesson.getCourseClassification();
		Institute courseIns = lesson.getInstitute();
		if((!courseIns.equals(studentIns)) && t.equals(CourseClassification.ZHUANYEKE))
			return true;
		return canQuit[t.ordinal()];
	}
	
	public boolean canCancelSelect(CourseClassification type) {
		return canCancelSelect[type.ordinal()];
	}
	
	public static QuitStrategy getInstance() {
		if(qs == null) {
			qs = new QuitStrategy();
		}
		return qs;
	}
}
